<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<div class="nav-tabs-custom">
	<ul class="nav nav-tabs">
		<li ng-class="{active: type === 'hourly'}"><a ng-click="switchType('hourly')">Hourly</a></li>
		<li ng-class="{active: type === 'daily'}"><a ng-click="switchType('daily')">Daily</a></li>
		<li ng-class="{active: type === 'weekly'}"><a ng-click="switchType('weekly')">Weekly</a></li>
		<li ng-class="{active: type === 'monthly'}"><a ng-click="switchType('monthly')">Monthly</a></li>
	</ul>
	<div class="tab-content">
		<div class="jpm-chart">
			<h3 class="text-center">Number of Submitted Jobs</h3>
			<div chart class="jpm-chart-container"
				 series="jobDistributionSeries"
				 category-func="jobDistributionCategoryFunc"
				 option="jobDistributionSeriesOption"
				 ng-click="distributionClick"></div>
			<div ng-if="(jobDistributionSeries || []).length === 0" class="overlay">
				<i class="fa fa-refresh fa-spin"></i>
			</div>
		</div>
	</div>
	<div class="box-body no-padding" ng-show="distributionSelectedIndex !== -1">
		<div class="row border-split">
			<div class="col-sm-12 col-md-6">
				<div class="jpm-chart overlay-wrapper">
					<h3 class="text-center">[{{distributionSelectedType}}] Top Job Count By User</h3>
					<div chart class="jpm-chart-container" series="topUserJobCountSeries" category="topUserJobCountSeriesCategory" option="commonChartOption"></div>
					<div ng-if="topUserJobCountSeries.length === 0" class="overlay">
						<i class="fa fa-refresh fa-spin"></i>
					</div>
				</div>
			</div>
			<div class="col-sm-12 col-md-6">
				<div class="jpm-chart overlay-wrapper">
					<h3 class="text-center">[{{distributionSelectedType}}] Top Job Count By Type</h3>
					<div chart class="jpm-chart-container" series="topTypeJobCountSeries" category="topTypeJobCountSeriesCategory" option="commonChartOption"></div>
					<div ng-if="topUserJobCountSeries.length === 0" class="overlay">
						<i class="fa fa-refresh fa-spin"></i>
					</div>
				</div>
			</div>
			<div class="col-sm-12 col-md-6">
				<div class="jpm-chart overlay-wrapper">
					<h3 class="text-center">[{{distributionSelectedType}}] Top Job Count Trend By User</h3>
					<div chart class="jpm-chart-container" series="topUserJobCountTrendSeries" category-func="drillDownCategoryFunc" option="commonTrendChartOption"></div>
					<div ng-if="topUserJobCountTrendSeries.length === 0" class="overlay">
						<i class="fa fa-refresh fa-spin"></i>
					</div>
				</div>
			</div>
			<div class="col-sm-12 col-md-6">
				<div class="jpm-chart overlay-wrapper">
					<h3 class="text-center">[{{distributionSelectedType}}] Top Job Count Trend By Type</h3>
					<div chart class="jpm-chart-container" series="topTypeJobCountTrendSeries" category-func="drillDownCategoryFunc" option="commonTrendChartOption"></div>
					<div ng-if="topUserJobCountTrendSeries.length === 0" class="overlay">
						<i class="fa fa-refresh fa-spin"></i>
					</div>
				</div>
			</div>
			<div class="col-sm-12 col-md-6" ng-show="!jobList">
				<div class="jpm-chart overlay-wrapper">
					<h3 class="text-center">[{{distributionSelectedType}}] Job Duration Distribution</h3>
					<div chart class="jpm-chart-container" series="jobDurationDistributionSeries" category="bucketDurationCategory" option="commonChartOption"></div>
					<div ng-if="jobDurationDistributionSeries.length === 0" class="overlay">
						<i class="fa fa-refresh fa-spin"></i>
					</div>
				</div>
			</div>
			<div class="col-sm-12 col-md-12" ng-show="jobList">
				<div class="overlay-wrapper">
					<div sort-table="jobList" style="margin-top: 10px;">
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>Job Id</th>
									<th>Job Name</th>
									<th>Type</th>
									<th>User</th>
									<th width="135">Start Time</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<a ui-sref="jpmDetail({siteId: site, jobId: item.tags.jobId})" target="_blank">{{item.tags.jobId}}</a>
									</td>
									<td>{{item.tags.jobName}}</td>
									<td>{{item.tags.jobType}}</td>
									<td>{{item.tags.user}}</td>
									<td>{{Time.format(item.startTime)}}</td>
								</tr>
							</tbody>
						</table>
					</div>

					<div ng-if="!jobList._done" class="overlay">
						<i class="fa fa-refresh fa-spin"></i>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
